#include <stdio.h>
#include <string.h>

char filename[FILENAME_MAX] = {0};

void clean_file(const char *filename) {
    FILE *ch;

    if ((ch = fopen(filename, "w")) != NULL) {
        fclose(ch);
    }
}

int put_cont(const char *filename, const char *cont, unsigned append) {
    FILE *ch = fopen(filename, append ? "a": "w");

    if (append && (fseek(ch, 0, SEEK_END)));

    if (ch == NULL) {
        return 0;
    }

    while (*cont) {
        fputc(*cont, ch);
        ++cont;
    }

    return fclose(ch);

}

 void print_cont(const char *filename) {
    FILE *ch = fopen(filename, "r");
    char c = 0;

    while ((c = fgetc(ch)) != EOF) {
        putchar(c);
    }

    fclose(ch);
}

void print_cont2(const char *filename) {
    FILE *ch = fopen(filename, "r");
    char str[127] = {0};

    int i =0;

    printf("sizeof(char):%lu\n", sizeof(long));

    printf("fread ... : %lu\n", fread(str, sizeof(char), 170, ch));

    //while ((fread(str, sizeof(char), 2, ch)) != EOF) {
    //   puts(str);
    //    i++;

    //    if (i==10) {
    //        break;
    //    }
    //}

    fclose(ch);
}



void main(void){

    char cont[127] = {0};

    strcpy(filename, "./test.txt");

    print_cont2(filename);

}
